package com.itheima.edu.day25DataGramDemo.day25_1UUID;

import java.io.*;
import java.net.Socket;

public class SendUpdate {
    public static void main(String[] args) throws IOException {
        //创建客户端的Socket对象，连接服务器，指定IP地址，指定端口号
        Socket socket = new Socket("127.0.0.1",10001);

        //创建缓冲流读取本地的文件
        BufferedInputStream bis = new BufferedInputStream(new FileInputStream("D:\\Develop\\javaCode\\itheima-edu-info-manager\\src\\com\\itheima\\edu\\day25DataGramDemo\\day25_1UUID\\test.jpg"));

        //创建网络中的输出流，将数据输出
        OutputStream os = socket.getOutputStream();
        BufferedOutputStream bos = new BufferedOutputStream(os);

        //是将数据通过网络写到服务器中去
        int b;
        while((b = bis.read()) != -1){
            bos.write(b);
        }

        bos.flush();

        socket.shutdownOutput();

        InputStream is = socket.getInputStream();
        BufferedReader br = new BufferedReader(new InputStreamReader(is));

        String s;
        while((s = br.readLine())!=null){
            System.out.println(s);
        }

        bis.close();
        socket.close();


    }
}
